//
//  LocationService.h
//  YuanXinBaiduMap
//
//  Created by 晏德智 on 16/9/26.
//  Copyright © 2016年 晏德智. All rights reserved.
//

#import <BMKLocationkit/BMKLocationManager.h>

typedef void (^BaiduLocationCompletionBlock)(BMKLocation * _Nullable location, NSError * _Nullable error);
typedef void (^BaiduLocationHeadingCompletionBlock)(BMKLocation * _Nullable location, CLHeading * _Nullable heading, NSError * _Nullable error);

#import "BaiduLocationOptions.h"

@interface BaiduLocationKitService : NSObject

// 持续定位回调
@property(nonatomic, copy) BaiduLocationCompletionBlock didUpdateLocation;
// 持续定位回调
@property(nonatomic, copy) BaiduLocationHeadingCompletionBlock didUpdateHeading;

/// 当前用户位置，返回坐标类型为当前设置的坐标类型
@property (nonatomic, readonly) BMKLocation *userLocation;

// TODO: todo->gjs,加两个block回调,用于弹框点击取消和确定时触发
// 弹框请求定位权限
+ (void)requestLocationAuthorization:(void (^)(BOOL))completeHandler;

/**
 *打开定位服务
 *需要在info.plist文件中添加(以下二选一，两个都添加默认使用NSLocationWhenInUseUsageDescription)：
 *NSLocationWhenInUseUsageDescription 允许在前台使用时获取GPS的描述
 *NSLocationAlwaysUsageDescription 允许永远可获取GPS的描述
 */
-(void)startUserLocationService;
/**
 *关闭定位服务
 */
-(void)stopUserLocationService;
/**
 *获取当前定位(单次定位)
 */
- (void)getCurrentPositionWithOptions:(BaiduLocationOptions)options completion:(BMKLocatingCompletionBlock)completionBlock;

#pragma mark - 定位参数，具体含义可参考CLLocationManager相关属性的注释

/// 设定定位的最小更新距离。默认为kCLDistanceFilterNone
@property(nonatomic, assign) CLLocationDistance distanceFilter;

/// 设定定位精度。默认为kCLLocationAccuracyBest。
@property(nonatomic, assign) CLLocationAccuracy desiredAccuracy;

/// 设定最小更新角度。默认为1度，设定为kCLHeadingFilterNone会提示任何角度改变。
@property(nonatomic, assign) CLLocationDegrees headingFilter;

/// 指定定位是否会被系统自动暂停。默认为YES。只在iOS 6.0之后起作用。
@property(nonatomic, assign) BOOL pausesLocationUpdatesAutomatically;

/// 指定定位：是否允许后台定位更新。默认为NO。只在iOS 9.0之后起作用。设为YES时，Info.plist中 UIBackgroundModes 必须包含 "location"
@property(nonatomic, assign) BOOL allowsBackgroundLocationUpdates;

/// 开启定位方向信息
@property(nonatomic, assign) BOOL enableHeadingUpdates;

@end
